import axios from 'axios';
const baseURL = 'https://ticar.zhixiangwangluo.com';
const $axios = axios.create({
    baseURL,
    timeout: 30000, // 30s超时
    withCredentials: true, // 跨域携带cookie
});
function post(action,data={},successCallback,failCallback){
    return $axios({
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
        },
        method: 'post',
        url: action,
        data,
    }).then((res) => {
        const { data } = res;
        if(data.code === 0){
            successCallback(data);
        }else{
            failCallback(data);
        }
    }).catch((err)=>{
        failCallback(err);
    });
}
export default {
    post
};
